package com.fish.yssb.ui.page.activity.realTime;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fish.yssb.R;
import com.fish.yssb.db.RealmDb;
import com.fish.yssb.db.bean.BaseInfoTable;
import com.fish.yssb.ui.page.activity.base.BaseActivity;
import com.fish.yssb.ui.page.activity.setPara.SetParaOneActivity;
import com.fish.yssb.ui.page.activity.setPara.SetParaThreeActivity;
import com.fish.yssb.ui.page.activity.setPara.SetParaTwoActivity;
import com.fish.yssb.ui.page.adapter.realtimeYMListAdapter;
import com.fish.yssb.ui.page.adapter.realtimeYXListAdapter;
import com.jaeger.library.StatusBarUtil;

import java.util.ArrayList;
import java.util.List;


/**
 * A login screen that offers login via email/password.
 */
public class RealTimeListYXActivity extends BaseActivity implements OnClickListener {
    private static final String TAG = RealTimeListYXActivity.class.getSimpleName();



    private RecyclerView recyclerView;
    private realtimeYXListAdapter adapter;

    TextView tv_back,tv_toptitle,tv_set;

   private RelativeLayout ll_para_1, ll_para_2, ll_para_3;

    public static void start(Context context) {
        Intent intent = new Intent(context, RealTimeListYXActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtil.setTransparent(this);
        StatusBarUtil.setDarkMode(this);
        setContentView(R.layout.activity_realtime_yx_list);
        initview();

    }


    //初始化视图
    @SuppressLint("WrongViewCast")
    private void initview() {
        tv_toptitle = findViewById(R.id.tv_toptitle);
        tv_toptitle.setText("遥信");
        //登录层、下拉层、其它登录方式层
        recyclerView = (RecyclerView) findViewById(R.id.recylerview);
        recyclerView.setHasFixedSize(true);


        recyclerView.setLayoutManager(new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL));
        recyclerView.setAdapter(adapter = new realtimeYXListAdapter());

        adapter.replaceAll(getData());

        tv_back = findViewById(R.id.tv_back);
        tv_set = findViewById(R.id.tv_set);
        tv_set.setOnClickListener(this);
        tv_back.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {


        switch (view.getId()) {

            case R.id.tv_back:
                finish();
                break;
            case R.id.tv_set:
                break;
            default:
                break;
        }


    }

    public ArrayList<BaseInfoTable> getData()
    {
        List<BaseInfoTable> list = (List<BaseInfoTable>) RealmDb.getInstance().queryRealmObjects(BaseInfoTable.class);

        Log.e("=========","count:"+list.size());
        ArrayList<BaseInfoTable> arrayList = (ArrayList) RealmDb
                .getInstance()
                .queryRealmObjectsByData(BaseInfoTable.class,"paraType",1);

        return arrayList;
    }
}